package com.ff.cms.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.websocket.Session;

import org.springframework.web.servlet.HandlerInterceptor;

import com.ff.cms.bean.User;

public class IsLoginInterceptor implements HandlerInterceptor {

	
	
	public  boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		if (user==null) {
			response.sendRedirect(request.getContextPath() + "/loginCtl/toLogin");
			return false;
		}else {
			return true;
		}
		}
		
}
